export class Game {
  static readonly LEVEL_COUNT = 10;
  private static _currentLevel = 1;

  // 关卡设置
  static readonly LEVEL_SETTINGS = [
    {
      id: 1,
      name: "Level 1",
      description: "This is the first level of the game.",
      food1: 1,
      food2: 2,
      answers: [
        1, 2, 3, 4
      ],
      rightAnswer: 3,
    },
  ];

  static get CURRENT_LEVEL(): number {
    return Game._currentLevel;
  }

  static set CURRENT_LEVEL(value: number) {
    Game._currentLevel = value;
  }

  // 单例模式
  private static _instance: Game;
  private constructor() {}
  public static getInstance(): Game {
    if (!Game._instance) {
      Game._instance = new Game();
    }
    return Game._instance;
  }

  getLevelCount(){
    return Game.LEVEL_COUNT;
  }

  getCurrentLevel(){
    return Game.CURRENT_LEVEL;
  }
  
  // 获取关卡设置
  public static getLevelSetting(level: number){
    return Game.LEVEL_SETTINGS[level - 1];
  }

  nextLevel(){
    Game.CURRENT_LEVEL++;
  }

  resetLevel(){
    Game.CURRENT_LEVEL = 1;
  }
}